home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / UTILITY / LSRC_222 / TEST_AFX.S < prev    next >
Encoding:
Text File  |  1993-07-26  |  2.7 KB  |  171 lines

  1.  
  2. _onoff            EQU 8
  3.  
  4.                 import    buffer_gen
  5.                 import    obj
  6.  
  7.                 export    test_afx
  8.                 export    afxonoff
  9.  
  10.  
  11. test_afx:        movem.l d3-d6/a2-a6,-(SP)
  12.                 move.l    a0,a4        ; path
  13.  
  14.                 move.l    buffer_gen,a5
  15.  
  16.                 clr.w    -(SP)
  17.                 pea        (a4)
  18.                 move.w    #$3D,-(SP)    ; Fopen
  19.                 trap    #1
  20.                 addq.w    #8,SP
  21.                 tst.l    D0
  22.                 bmi        _error
  23.  
  24.                 move.l    D0,D3        ; handle
  25.  
  26.                 pea        (a5)
  27.                 pea     2048.w
  28.                 move.w    D3,-(SP)
  29.                 move.w    #$3F,-(SP)    ; Fread
  30.                 trap    #1
  31.                 lea     12(SP),SP
  32.  
  33.                 move.l    d0,d4        ; len
  34.  
  35.                 move.w    D3,-(SP)
  36.                 move.w    #$3E,-(SP)    ; Fclose
  37.                 trap    #1
  38.                 addq.w    #4,SP
  39.  
  40.                 tst.l    d4
  41.                 bmi        _error
  42.  
  43.                 cmpi.w    #$601A,(a5)
  44.                 bne.b    no_prg
  45.  
  46.                 tst.l    14(a5)        ; ph_slen
  47.                 beq        is_prg
  48.  
  49.                 tst.l    22(a5)        ; ph_prgflags
  50.                 bne        is_prg
  51.  
  52.                 tst.b    obj
  53.                 beq.b    is_prg
  54.                 bra.b    unpacked
  55.  
  56. no_prg:            movea.l    a5,a1
  57.                 move.w    d4,d0
  58.                 subq.w    #1,d0
  59.                 moveq.l    #'-',d1
  60.                 moveq.l    #0,d3
  61.  
  62. search_header:    cmp.b    (a1)+,d1
  63.                 bne.b    cont_search
  64.                 cmp.b    3(a1),d1
  65.                 bne.b    cont_search
  66.  
  67.                 cmpi.b    #'l',(a1)
  68.                 beq.b    test_lzh
  69.                 cmpi.b    #'L',(a1)
  70.                 beq.b    test_lzh
  71.  
  72.                 cmp.b    #'a',(a1)
  73.                 bne.b    cont_search
  74.                 cmp.b    #'f',1(a1)
  75.                 bne.b    cont_search
  76.                 cmp.b    #'x',2(a1)
  77.                 seq        d3
  78.                 beq.b    test_lzh
  79.  
  80. cont_search:    dbra    d0,search_header
  81.                 bra.b    unpacked
  82.  
  83. test_lzh:        subq.l    #3,a1
  84.  
  85.                 cmp.b    #2,20(a1)
  86.                 beq.b    is_lzh
  87.  
  88.                 move.l    a1,a0
  89.                 moveq.l    #0,D0
  90.                 moveq.l    #0,D1
  91.                 moveq.l    #0,D2
  92.  
  93.                 move.b    (A0)+,D1
  94.                 move.b    (A0)+,D2
  95.                 subq.w    #1,D1
  96.  
  97. get_chk:        add.b    (A0)+,D0
  98.                 dbra    D1,get_chk
  99.  
  100.                 cmp.b    D0,D2
  101.                 seq        D0
  102.                 bne.b    unpacked
  103.  
  104.                 tst.w    d3
  105.                 bne.b    is_afx
  106.  
  107. is_lzh:         moveq    #2,D0
  108.                 bra.b    testx
  109.  
  110. _error:            moveq.l    #-1,D0
  111.                 bra.b    testx
  112.  
  113. unpacked:        moveq    #0,D0
  114.                 bra.b    testx
  115.  
  116. is_afx:         moveq    #1,D0
  117.                 bra.b    testx
  118.  
  119. is_prg:         moveq    #3,D0
  120. testx:            movem.l (SP)+,d3-d6/a2-a6
  121.                 rts
  122.  
  123.  
  124. afxonoff:        movem.l d3-d6/a2-a6,-(SP)
  125.                 bsr.b    find_afx
  126.                 cmpa.l    #0,A4
  127.                 beq.b    onofX
  128.                 move.l    _onoff(A4),D1
  129.                 move.l    D0,_onoff(A4)
  130.                 move.l    D1,D0
  131. onofX:            movem.l (SP)+,d3-d6/a2-a6
  132.                 rts
  133.  
  134. find_afx:        move.l    D0,-(SP)
  135.  
  136.                 clr.l    -(SP)
  137.                 move.w    #$20,-(SP)    ; Super
  138.                 trap    #1
  139.                 addq.l    #6,SP
  140.                 move.l    D0,-(SP)
  141.                 move.w    #$20,-(SP)
  142.  
  143.                 movea.l $84.w,A4
  144. find_afx1:        cmpi.l    #'XBRA',-12(A4)
  145.                 bne.b    no_afx
  146.                 cmpi.l    #'AFX ',-8(A4)
  147.                 beq.b    found_afx
  148.  
  149.                 movea.l -4(A4),A4
  150.                 move.l    a4,d0
  151.                 bne.b    find_afx1
  152.  
  153. no_afx:         trap    #1            ; Super
  154.                 addq.l    #6,SP
  155.                 suba.l    A4,A4
  156.                 move.l    (SP)+,D0
  157.                 rts
  158.  
  159. found_afx:        subq.l    #8,a4
  160.                 subq.l    #8,a4
  161.                 move.l    (A4),D0
  162.                 add.w    d0,a4
  163.                 cmpi.l    #'PARX',-4(A4)
  164.                 bne.b    no_afx
  165.                 trap    #1
  166.                 addq.l    #6,SP
  167.                 move.l    (SP)+,D0
  168.                 rts
  169.  
  170.                 END
  171.